package com.spzx.product.controller;

import com.spzx.common.core.web.domain.AjaxResult;
import com.spzx.common.core.web.page.TableDataInfo;
import com.spzx.product.domain.Brand;
import com.spzx.product.domain.Category;
import com.spzx.product.domain.CategoryBrand;
import com.spzx.product.service.CategoryBrandService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.spzx.common.core.web.controller.BaseController;

import java.util.List;

/**
 * <p>
 * 分类品牌 前端控制器
 * </p>
 *
 * @author atguigu
 * @since 2025-04-28
 */
@RestController
@RequestMapping("/categoryBrand")
public class CategoryBrandController extends BaseController {

    @Autowired
    private CategoryBrandService categoryBrandService;
    @Operation(summary = "分类品牌")
    @GetMapping("list")
    public TableDataInfo selectall(){
        List<CategoryBrand> list =categoryBrandService.sellectalltwo();
        return getDataTable(list);
    }
    @Operation(summary = "增加种类")
    @PostMapping
    public AjaxResult savedate(@RequestBody CategoryBrand categoryBrand){
        categoryBrandService.savealldate(categoryBrand);
        return AjaxResult.success();
    }
    @Operation(summary = "删除品类")
    @DeleteMapping("{ids}")
    public AjaxResult deletebyid(@PathVariable("ids") List<Long> ids){
        categoryBrandService.removeBatchByIds(ids);
        return AjaxResult.success();
    }
    @Operation(summary = "根据三级id查品牌列表")
    @GetMapping("brandList/{categoryId}")
    public AjaxResult getbrand(@PathVariable("categoryId") Long categoryId){
        List<Brand> list= categoryBrandService.getbrands(categoryId);
        return AjaxResult.success(list);
    }

}
